package com.woniu.controller.backpage;

import com.alibaba.fastjson.JSONObject;
import com.woniu.util.MinioUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 李松桦
 * @data 2023/3/9 10:56
 */
@RestController
public class ImgLoadTwoController {
    @Autowired
    MinioUtils minioUtils;

    @PostMapping ("/imgUpload")
    public String imgUpload(MultipartFile file){
        JSONObject res = null;
        try {
           res = minioUtils.uploadFile(file,"wnsximg");
        } catch (Exception e) {
            e.printStackTrace();
            res.put("code", 0);
            res.put("msg", "上传失败");
        }
        return res.toJSONString();
    }
}
